export default {
	isLogin: false,
	userinfo: {
		id: '',
		username: '',

	},
	imageSrc: 'http://123.57.7.108:81/',
	login: function(data) {
		//箭头函数中没有自己this			
		try {
			uni.setStorageSync('login_token_key', data.token);
			uni.setStorageSync('login_user_id', data.user.id);

			//我的用戶名 //我的Id
		} catch (e) {

		}
		console.log(this)
		this.isLogin = true;
		this.userinfo = data.user;


	},
	logout: function() {
		this.isLogin = false;
		this.userinfo = {};
		try {
			uni.clearStorageSync();
		} catch (e) {
			// error
		}


	},
	//如果token存在，重置登陆状态
	relogin:function(){
		this.isLogin=true;
		try{
			let  id_value=uni.getStorageSync("login_user_id")
			if(id_value){
				this.userinfo.id=id_value;
			}
		}catch(ex){
			
		}
		
		
		
		
	}


}
